home *** CD-ROM | disk | FTP | other *** search
- /*
- ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
- ▒ ▒
- ▒ ▒
- ▒ Neuromancer's Graphics Library ▒
- ▒ Version 1.0c ▒
- ▒ ▒
- ▒ This program attempts to illustrate all the features ▒
- ▒ of the mtGraph library. ▒
- ▒ ▒
- ▒ A very fast hack on the animation routine and ▒
- ▒ make sure the log.blt is in the same directory. ▒
- ▒ ▒
- ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
- ▒ ▒
- ▒ Project: MTLIB01.LIB ▒
- ▒ MTDEMO.CPP ▒
- ▒ ▒
- ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
- */
- #include <iostream.h>
- #include <conio.h>
- #include <stdlib.h>
- #include <dos.h>
- #include "video.h"
- #include "fonts.h"
- #include "palette.h"
- #include "circle.h"
- #include "line.h"
- #include "rect.h"
- #include "mouse.h"
- #include "ellipse.h"
- #include "sound.h"
- #include "key.h"
- #include "bitmap.h"
-
-
- extern SPRITE_HEADER *sprite_header;
- extern FONT_HEADER *font_header;
- FONT **font;
- int kxcor, kycor, flag=0;
-
- byte sprite2[] = {
- /*20,20,*/
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 75, 75,
- 75, 75, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75
-
- };
-
- byte sprite3[]={
- //20,20
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75
- };
-
- byte sprite4[]={
- //20,20
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
- 75, 75, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 75, 75,
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75
- };
-
-
- byte sprite5[]={
- //20,20
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 45, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 80, 80, 80, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 75, 75,
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75,
- 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75
- };
-
-
- block page1,page2;
-
- void Click()
- {
- /* mtSound(200,3000);
- delay(5);
- mtSound(500,2000);
- delay(5);
- mtSound(100,3000);*/
-
- for(register int i = 100; i< 1500; i+=2)
- sound(i);
- for(register int j =1500; j>100;j-=2)
- sound(j);
- nosound();
-
- }
-
- int Show_Palette_Routine()
- {
- byte palette[768];
- byte palblack[768];
-
- mtClearPal(palblack);
-
- if ((page1 = mtAllocPage(0,0,319,199))==NULL)
- {
- return 1;
- }
-
- mtSetPage(PAGE_1);
- if (mtLoadPCX("poolball.dat")==0)
- {
- return 1;
- }
-
- mtGetAllPal(palette);
- mtSetPal(palblack,0,255);
- mtFlipPage(PAGE_1);
-
- mtFadeIn(palette,1,40);
-
- getch();
-
- mtFadeOut(30);
-
- mtSetPage(PAGE_0);
-
- mtClrScr(0);
-
- mtSetPage(PAGE_1);
- mtLoadPCX("pacman.dat");
- mtFlipPage(PAGE_1);
-
- return 0;
-
- }
-
- void Pixel_Routine()
- {
- randomize();
-
- mtSetWindow(15,15,304,184); //set up clip region
-
- while(!kbhit())
- {
- mtCPutPixel( random(320),random(200),random(256));
- }
-
- }
-
-
- void Line_Routine()
- {
- while(!kbhit())
- {
- mtCLine( random(320),random(200),random(320), random(200), random(256));
- }
- }
-
- void Circle_Routine()
- {
-
- int x,y,major,color;
-
- randomize();
-
- while(!kbhit())
- {
- x = random(320)+1;
- y = random(200)+1;
- major = random(40);
- color = random(256);
-
- if ((major < x ) || (major < y))
- {
- mtCCircle(x,y,major,color);
- }
- }
-
- getch();
-
- while(!kbhit())
- {
- x = random(320)+1;
- y = random(200)+1;
- major = random(40);
- color = random(256);
-
- if ((major < x ) || (major < y))
- {
- mtCFillCircle(x,y,major,color);
- }
- }
-
- }
-
- void Ellipse_Routine()
- {
- int x,y,major,minor,color;
-
- while(!kbhit())
- {
- x = random(320)+1;
- y = random(200)+1;
- major = random(40);
- color = random(256);
- minor = random(40);
-
- mtCEllipse(x,y,major,minor,color);
-
- }
-
- getch();
-
- while(!kbhit())
- {
- x = random(320)+1;
- y = random(200)+1;
- major = random(40);
- color = random(256);
- minor = random(40);
-
- mtCFillEllipse(x,y,major,minor,color);
-
- }
-
-
- }
-
-
- void Rect_Routine()
- {
- while(!kbhit())
- {
- mtCRect(random(320),random(200),random(320),random(200), random(256));
- }
-
- getch();
-
- while(!kbhit())
- {
- mtCFillRect(random(320),random(200),random(320),random(200), random(256));
- }
- }
-
-
- int Mouse_Routine()
- {
- int button=-1,xm=0,ym=0;
-
- if (mtInitMouse()==0){
- return 1;
- }
-
- mtShowMouse();
-
- do
- {
- mtGetMousePos(&button, &xm, &ym);
-
- }while(button<=0);
-
- mtHideMouse();
-
- return 0;
-
- }
-
-
- int Animation_Routine()
- {
-
- int xcor;
- int ycor;
-
- int xcor1;
- int ycor1;
-
- int xdir;
- int ydir;
-
- int xdir1;
- int ydir1;
- int flag=0;
- int inc=0;
- int flag1=0,inc1=0;
- int flag2;
- int ch;
-
- SPRITE **sprite;
- byte palette[768];
-
- if ((sprite=mtLoadBlit("log",palette)) == NULL)
- {
- return 1;
- }
-
- xcor = random(297);
- ycor = random(170);
- xcor1 =random(3);
- ycor1 =random(1);
-
- xdir = 10;
- ydir = 5;
- xdir1 =5;
- ydir1 =5;
- flag=0;
- inc=0;
- flag1=0;
- inc1=0;
- flag2=0;
-
- if ((page2=mtAllocPage(0,0,319,199))==NULL)
- {
- return 1;
- }
-
- mtCopyPage(PAGE_1,PAGE_2);
-
- mtSetPage(PAGE_1);
-
- while(!kbhit())
- {
- xcor += xdir;
- ycor += ydir;
-
- xcor1 += xdir1;
- ycor1 += ydir1;
-
- if (xcor < 0 || xcor > 290 ) {
- xdir = -xdir;
- xcor += xdir;
- }
-
- if (ycor <0|| ycor >160) {
- ydir = -ydir;
- ycor += ydir;
- }
-
- if (xcor1<0||xcor1 >300) {
- xdir1 = -xdir1;
- xcor1 += xdir1;
- }
-
- if (ycor1 <0 || ycor1>179) {
- ydir1 = -ydir1;
- ycor1 += ydir1;
- }
-
-
- if(flag1==0){
- mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
- inc1++;
- if (inc1 == 1) flag1 =1;
- }
- else
- if(flag1==1){
- mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
- inc1++;
- if (inc1 == 2) flag1 =2;
- }
- else
- if(flag1==2){
- mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
- inc1++;
- if (inc1 == 3) flag1 =3;
- }
- else
- if(flag1==3){
- mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
- inc1++;
- if (inc1 == 4) flag1 =4;
- }
- else
- if(flag1==4){
- mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
- inc1++;
- if (inc1 == 5) flag1 =5;
- }
- else
- if(flag1==5){
- mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
- inc1++;
- if (inc1 == 6) flag1 =6;
- }
- else
- if(flag1==6){
- mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
- inc1++;
- if (inc1 ==7) flag1 =7;
- }
- else
- if(flag1==7){
- mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
- inc1++;
- if (inc1 == 8) flag1 =8;
- }
- else
- if(flag1==8){
- mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
- inc1++;
- if (inc1 == 9) flag1 =9;
- }
- else
- if(flag1==9){
- mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
- inc1++;
- if (inc1 == 10) flag1 =10;
- }
- else
- if(flag1==10){
- mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
- inc1++;
- if (inc1 == 11) flag1 =11;
- }
- else
- if(flag1==11){
- mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
- inc1++;
- if (inc1 == 12) flag1 =12;
- }
- else
- if(flag1==12){
- mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
- inc1++;
- if (inc1 == 13) flag1 =13;
- }
- else
- if(flag1==13){
- mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
- inc1++;
- if (inc1 == 14) flag1 =14;
- }
- else
- if(flag1==14){
- mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
- inc1++;
- if (inc1 == 15) flag1 =15;
- }
- else
- if(flag1==15){
- mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
- inc1++;
- if (inc1 == 16) flag1 =16;
- }
- else
- if(flag1==16){
- mtCPutSprite(xcor,ycor,sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
- inc1++;
- if (inc1 == 17) flag1 =17;
- }
- else
- if(flag1==17){
- mtCPutSprite(xcor, ycor, sprite[flag1]->width,sprite[flag1]->height,sprite[flag1]->data);
- inc1++;
- if (inc1 == 18)
- {
- flag1 =0;
- inc1 =0;
- }
- }
-
- if (flag ==0){
- mtCPutSprite(xcor1, ycor1, 20, 20, sprite2); //sprite mode
- inc++;
- if (inc == 1) flag = 1;
- }
- else
- if (flag==1)
- {
- mtCPutSprite(xcor1, ycor1, 20, 20, sprite4); //sprite mode
- inc++;
- if (inc==2) flag=2;
- }
- else
- if (flag==2)
- {
- mtCPutSprite(xcor1, ycor1, 20, 20, sprite3); //sprite mode
- inc++;
- if (inc==3) flag=3;
- }
- else
- if (flag==3)
- {
- mtCPutSprite(xcor1, ycor1, 20, 20, sprite5); //sprite mode
- inc++;
- if (inc==4)
- {
- flag=0;
- inc=0;
- }
- }
-
- mtWaitRetrace();
- mtFlipPage(PAGE_1);
- if (flag1==0) flag2 =17;
- else
- flag2 = flag1-1;
- mtCopyBlk(xcor,ycor,xcor+(sprite[flag2]->width)-1,ycor+(sprite[flag2]->height)-1,xcor,ycor,PAGE_2,PAGE_1);
- mtCopyBlk(xcor1,ycor1,xcor1+19,ycor1+19,xcor1,ycor1,PAGE_2,PAGE_1);
-
- }
-
- getch();
-
- mtFreeBlit(sprite);
-
- mtFreePage(page2);
-
- mtSetPage(PAGE_0);
- mtClrScr(0);
-
- return 0;
-
- }
-
- extern byte key[128];
-
- void getkey()
- {
-
- if (key[ARROW_UP]==1 && kycor>1)
- {
- Click();
- kycor -= 10;
- if (flag < sprite_header->total)
- flag += 1;
- else
- flag = 0;
- }
- if (key[ARROW_DOWN]==1 && kycor<190)
- {
- Click();
- kycor += 10;
- if (flag > 0)
- flag -= 1;
- else
- flag = sprite_header->total;
- }
- if (key[ARROW_LEFT]==1 && kxcor >1 )
- {
- Click();
- kxcor -= 10;
- if (flag < sprite_header->total)
- flag += 1;
- else
- flag = 0;
- }
- if (key[ARROW_RIGHT]==1 && kxcor < 310)
- {
- Click();
- kxcor += 10;
- if (flag > 0)
- flag -= 1;
- else
- flag = sprite_header->total;
- }
- }
-
- int Keyboard_Routine()
- {
-
- SPRITE **sprite;
- byte palette[768];
-
-
- if ((sprite=mtLoadBlit("testbmp",palette)) == NULL)
- {
- return 1;
- }
-
- kxcor = 10; kycor = 10;
-
- mtKeyInst();
- mtSetPal(palette,0,255);
-
-
- if ((page2=mtAllocPage(0,0,319,199))==NULL)
- {
- mtKeyUninst();
- return 1;
- }
-
- mtSetPage(PAGE_1);
- // mtLoadPCX("pacman.dat");
- mtCopyPage(PAGE_1,PAGE_2);
-
- while(!key[KEY_ESC])
- {
- getkey();
- mtCPutSprite(kxcor, kycor,sprite[flag]->width,sprite[flag]->height,sprite[flag]->data);
-
- mtFlipPage(PAGE_1);
- mtCopyBlk(kxcor,kycor,kxcor+(sprite[flag]->width)-1,kycor+(sprite[flag]->height)-1,kxcor,kycor,PAGE_2,PAGE_1);
- }
-
- mtFreePage(page2);
- mtFreeBlit(sprite);
- mtKeyUninst();
-
- mtSetPage(PAGE_0);
- mtClrScr(0);
-
- return 0;
-
- }
-
- void main(void)
- {
- byte palette[768];
-
- mtSetVGAMode(); //Set up VGA Mode
-
- font=mtLoadFont("default.fon");
-
- mtClrScr(0);
-
- mtPrintStr(105,50,"WELCOME TO",font);
- mtPrintStr(35,70,"THE MTGRAPH TOOLKIT DEMO",font);
- mtPrintStr(33,170,"Press any Key to Continue",font);
-
- getch();
-
- mtClrScr(0);
-
- if (Show_Palette_Routine() == 1)
- {
- mtFreeFont(font);
- mtFreePage(page1);
- mtSetTextMode();
- cout << "Error encountered! Exiting.."<< endl;
- exit(0);
- }
-
- mtPrintStr(33,170,"Press any Key to Continue",font);
-
- getch();
-
- mtSetPage(PAGE_0);
- Pixel_Routine();
-
- getch();
-
- Line_Routine();
-
- getch();
-
- Circle_Routine();
-
- getch();
-
- Rect_Routine();
-
- getch();
-
- Ellipse_Routine();
-
- getch();
-
- mtWaitRetrace();
- mtFlipPage(PAGE_1);
-
- getch();
-
- mtSetWindow(0,0,319,199);
- // mtSetPage(PAGE_0);
- // mtClrScr(0);
-
- if (Keyboard_Routine() == 1)
- {
- mtFreeFont(font);
- mtFreePage(page1);
- mtSetTextMode();
- cout << "Error encountered in Keyboard Routine! Exiting.."<< endl;
- exit(0);
- }
-
- mtSetPage(PAGE_1);
- mtLoadPCX("screen1.dat");
-
- mtWaitRetrace();
- mtFlipPage(PAGE_1);
-
- Mouse_Routine();
-
- mtSetPage(PAGE_0);
- mtPrintStr(30,20,"Now for some Animation Examples",font);
- mtPrintStr(48,170,"Press Any Key to continue",font);
-
- getch();
-
- if(Animation_Routine()== 1)
- {
- mtFreeFont(font);
- mtFreePage(page1);
- mtSetTextMode();
- cout << "Error encountered in Animation Routine! Exiting.."<< endl;
- exit(0);
- }
-
- mtClrScr(0);
- mtPrintStr(70,60,"THAT'S ALL FOLKS!",font);
-
- getch();
-
- mtFreeFont(font);
- mtFreePage(page1);
-
- mtSetTextMode();
-
- cout << "Thank you for using the library!" << endl;
-
- exit(0);
-
- }
-
-
-
-
-
-
-
-
-